package com.superman.view;

import com.alibaba.fastjson.JSON;
import com.superman.entity.User;
import com.superman.socket.TCPClient;

import java.io.IOException;

public class Login {
    public User login(String username, String password){
        User user = new User(username, password);
        User userReturn = null;

        try {
            userReturn = JSON.parseObject(TCPClient.getResponse("login#" + JSON.toJSONString(user)), User.class);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            return userReturn;
        }
    }
}
